﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class AnchorTagVisitor : VisitorBase
    {
        public AnchorTagVisitor(VisitorContext context)
            : base(context)
        {
        }

        public override void VisitNode(HtmlNode node)
        {
            if (this.ValidateRule())
            {
                if (node.Is("A"))
                {
                    var anchorTag = Provider.Factory.GetProvider<IAnchorTag>();
                    anchorTag.CustomType = node.Attr("ctype");
                    anchorTag.Node = node;
                    this.Context.Result.AnchorTags.Add(anchorTag);
                }
            }
        }

        protected override FuncType ExclusiveType
        {
            get
            {
                return FuncType.ListItemLink | FuncType.MenuLink;
            }
        }
    }
}
